<div class="md-modal md-effect-2" id="modal-2">
    <div class="md-content">
        <div class="modal-header">
            <button class="md-close close" >&times;</button>
            <h4 class="modal-title">终止订单\退单页面</h4>
        </div>
        <div class="modal-body">
            <form role="form">

                <div class="form-group">
                    <label  >终止订单\退单原因</label>
                    <input  class="form-control"  type="text" value="" autofocus="autofocus" ng-model="reason" >
                </div>


            </form>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-primary"   ng-click="saveBackOrder(reason,'终止审核')">终止订单</button>
            <button type="button" class="btn btn-primary"   ng-click="saveBackOrder(reason,'退单审核')">退单</button>
        </div>
    </div>
</div>
<!--开始试工-->
<div  class="md-modal md-effect-2" id="modal-4" >
    <div class="md-content"  style=" overflow-y:auto; overflow-x:auto; width:700px; height:600px;">
        <div class="modal-header">
            <button class="md-close close" >&times;</button>
            <h4 class="modal-title">开始试工页面</h4>
        </div>
        <div class="modal-body">
            <form role="form" name="myForm">

                <div class="form-group">
                    <!--<label  >试工工资</label>
                     <input  class="form-control"  type="text" value="" autofocus="autofocus" ng-model="reason" >-->
                    <label>协议编号</label>
                    <input  class="form-control"  name="number" type="text" value="" autofocus="autofocus"  ng-model="ContractInfo.number"  ng-required="true" ng-minlength="1"  placeholder="请输入协议编号">
                    <label>甲方（客户）</label>
                    <input  class="form-control"  type="text" value="" ng-model="ContractInfo.name" autofocus="autofocus"  placeholder="请输入甲方姓名">
                    <label>甲方地址</label>
                    <input  class="form-control"  type="text" value="" ng-model="ContractInfo.address" autofocus="autofocus"  placeholder="请输入甲方地址">
                    <label>甲方联系方式</label>
                    <input  class="form-control"  type="text" value="" ng-model="ContractInfo.phone" autofocus="autofocus"  placeholder="请输入甲方联系方式">
                    <label>乙方（家政人员）</label>
                    <input  class="form-control"  type="text" value="" ng-model="ContractInfo.selected_servant_name"  autofocus="autofocus"  disabled>
                    <label>乙方联系方式</label>
                    <input  class="form-control"  type="text" value="" ng-model="ContractInfo.selected_servant_phone"  autofocus="autofocus"  disabled>
                    <label>丙方（家政服务公司）</label>
                    <input  class="form-control"  type="text" value="" ng-model="ContractInfo.selected_company_name"  autofocus="autofocus"  disabled>
                    <label>丙方联系方式</label>
                    <input  class="form-control"  type="text" value="" ng-model="ContractInfo.selected_company_phone" autofocus="autofocus" >
                    <label>服务项目</label>
                    <input  class="form-control"  type="text" value="" ng-model="ContractInfo.serviceType2_title" autofocus="autofocus"  disabled>
                    <label>试工期（单位：日）</label>
                    <input type="text" class="form-control" name="time1" ng-required="true" ng-model="ContractInfo.time1" oninput="if (! /^([0-9]\d?|100)$/ig.test(this.value)){this.value='';};" placeholder="请输入试工期">
                    <label>试工开始时间</label>
                    <input type="text" class="form-control"  name="time2" id="time2"   ng-model="ContractInfo.time2" ng-required="true" placeholder="请输入试工开始时间" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})">
                    <label>试工期工资</label>
                    <input  class="form-control"  type="number" value="" ng-model="ContractInfo.probation_money" autofocus="autofocus"  placeholder="请输入试工期工资">
                    <label>甲方预交押金（若要求丙方不在场的情况下乙方直接上门试工,甲方需预交押金）</label>
                    <input type="text" class="form-control"  ng-model="ContractInfo.foregift" oninput="if (! /^[0-9]{1,20}$/ig.test(this.value)){this.value='';};"  placeholder="请输入预交押金">
                </div>


            </form>
        </div>
        <div class="modal-footer">
            <!--<button type="button" class="btn btn-primary"   ng-click="updateOrderStatus(item.order_id,'试工中')">开始试工</button>-->
            <button type="button" class="btn btn-primary"   ng-click="setContractProbation(ContractInfo,'试工中')">开始试工</button>
        </div>
    </div>
</div>
<div class="md-modal md-effect-2" id="modal-1">
    <div class="md-content">
        <div class="modal-header">
            <button class="md-close close"  >&times;</button>
            <h4 class="modal-title">金额</h4>
        </div>
        <div class="modal-body">
            <form role="form">

                <div class="form-group">
                    <label  >金额</label>
                    <input  class="form-control"  type="number" value=""   ng-model="amount" >
                </div>
            </form>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-primary"   ng-click="orderAmount(amount)">保存</button>

        </div>
    </div>
</div>

<div class="md-modal md-effect-3" id="modal-5">
    <div class="md-content">
        <div class="modal-header">
            <button class="md-close close">&times;</button>
            <h4 class="modal-title">选择当前服务人员</h4>
        </div>
        <div class="modal-body">
            <div class="row">
                <div class="col-lg-12">
                    <div class="filter-block pull-left">
                        <div class="form-group pull-left">
                            <input type="text" class="form-control" placeholder="请输入姓名" ng-model="searchOfServant.name"/>
                        </div>

                        <a class="btn btn-success pull-left form-group" ng-click="getServantList()">搜索</a>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="main-box no-header clearfix">
                        <div class="main-box-body clearfix">
                            <div class="table-responsive">
                                <table class="table table-hover table-striped text-center">
                                    <thead>
                                    <tr>
                                        <th class="text-center"><span>服务人员列表</span></th>
                                        <th class="text-center"><span>操作</span></th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr role="row" class="odd" ng-repeat="item in servantList">
                                        <td>{{item.name}}</td>
                                        <td>
                                            <a class="btn btn-primary" ng-click="setServant(item)">选择</a>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                            <ul class="pagination pull-right">
                                <li><a ng-click="changePageOfServant(1)">首页</a></li>
                                <li><a ng-show="currentPageOfServant>1" ng-click="changePageOfServant(currentPageOfServant-1)"><i class="fa fa-chevron-left"></i></a></li>
                                <li ng-repeat="item in pageListOfServant" ng-click="changePageOfServant(item.number)" class="{{item.active}}"><a>{{item.number}}</a></li>
                                <li><a ng-show="currentPageOfServant<totalPageOfServant" ng-click="changePageOfServant(currentPageOfServant+1)"><i class="fa fa-chevron-right"></i></a></li>
                                <li><a ng-click="changePageOfServant(totalPageOfServant)">尾页</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="col-lg-12">
    <!--当前位置 start-->
    <div class="row">
        <div class="col-lg-12">
            <ol class="breadcrumb">
                <li><a><i class="fa fa-home mrg-r-sm"></i>首页</a></li>
                <li class="active"><span>工单历史</span></li>
            </ol>
            <div class="filter-block pull-left">
                <!--搜索框 Start1-->
                <div class="form-group pull-left">
                    <input type="text" class="form-control" ng-model="search.start_time" id="start_time" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"  placeholder="请输入开始时间">
                </div>
                <div class="form-group pull-left">
                    ~
                </div>
                <div class="form-group pull-left">
                    <input type="text" class="form-control" ng-model="search.end_time" id="end_time"  onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" placeholder="请输入结束时间">
                </div>
                <div class="form-group pull-left">
                    <input type="text" class="form-control" ng-model="search.order_id"  placeholder="请输入订单号">
                </div>
                <div class="form-group pull-left">
                    <input type="text" class="form-control" ng-model="search.card_number"  placeholder="请输入卡号">
                </div>
                <div class="form-group pull-left">
                    <input type="text" class="form-control" ng-model="search.username"  placeholder="请输入联系人" >
                </div>
                <div class="form-group pull-left">
                    <input type="text" class="form-control" ng-model="search.phone"  placeholder="请输入电话">
                </div>
                <div class="form-group pull-left">
                    <select class="form-control"  ng-model="search.serviceType3_code"  ng-options=" service3.code as service3.title for service3 in service3_list" >
                        <option value="">请选择服务项目</option>
                    </select>
                </div>
                <div class="form-group pull-left">
                    <select class="form-control"  ng-model="search.own">
                        <option value="">请选择订单类型</option>
                        <option value="2" >养老</option>
                        <option value="1">家政</option>
                    </select>
                </div>
                <div class="form-group pull-left">
                    <select class="form-control"  ng-model="search.status">
                        <option value="">请选择订单状态</option>
                        <!--<option value="待受理" >待受理</option>-->
                        <option value="已接单">已接单</option>
                        <option value="试工中"  >试工中</option>
                        <option  value="服务中" >服务中</option>
                        <option value="待回访" >待回访</option>
                        <option value="完成" >完成</option>
                        <option value="终止订单" >终止订单</option>
                        <option value="终止审核" >终止审核</option>
                    </select>
                    <input type="hidden" ng-model="search.more_status" ng-init="search.more_status='已接单|试工中|服务中|完成|已回访|终止订单|待回访|终止审核'"/>
                </div>
                <!--搜索框 End-->
                <a class="btn btn-success pull-left form-group" ng-click="searchOrder(search)">
                    搜索
                </a>
                <a class="btn btn-success pull-left form-group" ng-click="export(search)">
                    导出
                </a>
                <a hidden="" id="exportUrl"  href="{{export_url}}" class="ng-scope pull-left" style="display: none;"><font class="btn btn-success pull-left form-group">点击下载</font></a>
            </div>
        </div>
    </div>
    <!--当前位置 end-->

    <!--代码写在这里-->
    <div class="row">
        <div class="col-lg-12">
            <div class="main-box no-header clearfix">

                <div class="main-box-body clearfix" >
                    <div class="table-responsive">
                        <table class="table table-hover table-striped text-center">
                            <thead >
                            <tr>
                                <th class="text-center"><span>订单号</span></th>
                                <th class="text-center"><span>服务项目</span></th>
                                <th class="text-center"><span>联系人</span></th>
                                <th class="text-center"><span>联系电话</span></th>
                                <th class="text-center"><span>下单时间</span></th>
                                <th class="text-center"><span>订单状态</span></th>
                                <th class="text-center"><span>当前服务人员</span></th>
                                <th class="text-center"><span>订单状态更改</span></th>
                                <th class="text-center"><span>操作</span></th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr role="row" class="odd" ng-repeat="item in list" id="{{item.order_id}}" on-finish-render-filters>
                                <td><span ng-if="item.fx == 1" style="color: cornflowerblue; font-size: 12px; vertical-align: text-top;">[分享]</span></br><span ng-if="item.cross_app_id == baas_yl_app_id" style="color: #ff0000; font-size: 12px; vertical-align: text-top;">[养老]</span>{{item.order_id}}
                                    <br><span ng-if="item.card_number" style="color: #ff0000; font-size: 12px; vertical-align: text-top;">卡号:{{item.card_number}}</span>

                                </td>
                                <td>{{item.serviceType3_title}}</td>
                                <td>{{item.name}}</td>
                                <td>{{item.phone}}</td>
                                <td>{{item.create_time}}</td>
                                <td>
                                    <span ng-class="{'待受理': 'label-default', '已接单': 'label-warning','试工中':'label-info','服务中':'label-info','完成':'label-success','已回访':'label-success','终止订单':'label-danger','退单':'label-danger'}[item.status]" class="label label-default">{{item.status}}</span>
                                </td>
                                <td>
                                    <!--<select  ng-if="item.status=='已接单'" ng-change="changeServant(item.order_id,item.selected_servant_id)"  class="form-control"  ng-model="item.selected_servant_id"   ng-options="servant.servant_id as servant.name group by servant.group  for servant in servantList">
                                        <option value="">请选择服务人员</option>
                                    </select>-->
                                    <a href="javascript:void(0);" ng-if="item.status=='已接单'"  class="md-trigger" data-modal="modal-5"
                                       ng-click="selServantWin(item)">
                                        <span ng-if="item.selected_servant_name==''|| item.selected_servant_name==undefined">请选择服务人员</span>
                                        <span ng-if="item.selected_servant_name!=''&& item.selected_servant_name!=undefined">{{item.selected_servant_name}}</span>
                                    </a>
                                    <span ng-if="item.status!='已接单'" >{{item.selected_servant_name}}</span>
                                </td>
                                <td>
                                    <a ng-if="(item.is_trial=='1') && item.status=='已接单'" class="md-trigger btn  btn-primary" data-modal="modal-4" ng-click="setContractInfo(item)"  >开始试工</a>
                                    <a ng-if="item.status=='试工中'" class="btn  btn-primary" ng-click="updateOrderStatus_begin(item,'服务中')">开始服务</a>
                                    <a ng-if="(item.is_trial!='1')&&item.status=='已接单'" class="btn  btn-primary" ng-click="updateOrderStatus_begin(item,'服务中')">开始服务</a>

                                    <a ng-if="(item.is_trial!='1')&&item.status=='服务中'"  data-modal="modal-1" ng-click="openWindow(item.order_id)" class="md-trigger btn  btn-primary" >完成服务</a>

                                    <a ng-if="(item.is_trial=='1')&&item.status=='服务中'" class="btn  btn-primary" ng-click="updateOrderStatus(item.order_id,'待回访')">完成服务</a>

                                    <span   ng-if="item.status == '完成' || item.status == '已回访'|| item.status == '终止订单'">完成服务</span>
                                </td>


                                <!--<td>
                                    <a ng-if="(item.is_trial=='1'||item.serviceType2_code=='baomu'||item.serviceType2_code=='yuying'||item.serviceType2_code=='peihu') && item.status=='已接单'" class="md-trigger btn  btn-primary" data-modal="modal-4" ng-click="setContractInfo(item)"  >开始试工</a>
                                    <a ng-if="item.status=='试工中'" class="btn  btn-primary" ng-click="updateOrderStatus(item.order_id,'服务中')">开始服务</a>
                                    <a ng-if="(item.is_trial!='1' &&item.serviceType2_code!='baomu'&&item.serviceType2_code!='yuying'&&item.serviceType2_code!='peihu')&&item.status=='已接单'" class="btn  btn-primary" ng-click="updateOrderStatus(item.order_id,'服务中')">开始服务</a>

                                    <a ng-if="(item.is_trial!='1' &&item.serviceType2_code!='baomu'&&item.serviceType2_code!='yuying'&&item.serviceType2_code!='peihu')&&item.status=='服务中'"  data-modal="modal-1" ng-click="openWindow(item.order_id)" class="md-trigger btn  btn-primary" >完成服务</a>

                                    <a ng-if="(item.is_trial=='1' ||item.serviceType2_code=='baomu'||item.serviceType2_code=='yuying'||item.serviceType2_code=='peihu')&&item.status=='服务中'" class="btn  btn-primary" ng-click="updateOrderStatus(item.order_id,'待回访')">完成服务</a>

                                    <span   ng-if="item.status == '完成' || item.status == '已回访'|| item.status == '终止订单'">完成服务</span>
                                </td>-->
                                <td>

                                    <!--<a class="btn  btn-primary" href="#/orderEdit/detail/{{item.order_id}}" >查看详情</a>-->
                                    <a href="#/orderEdit/detail/{{item.order_id}}" class="table-link" title="查看详情">
												<span class="fa-stack">
												<i class="fa fa-square fa-stack-2x"></i>
												<i class="fa fa-search-plus fa-stack-1x fa-inverse"></i>
												</span>
                                    </a>

                                    <!--<a  class="md-trigger  btn  btn-primary" data-modal="modal-2" ng-if="item.status == '已接单' || item.status == '使用中' || item.status =='试工中'" ng-click="openWindow(item.order_id)">退单/终止</a>-->

                                    <!--ng-click="backOrder(item.order_id)"-->
                                    <a class="md-trigger table-link danger " data-modal="modal-2" ng-if="item.status == '已接单' || item.status == '使用中' || item.status =='试工中'" ng-click="openWindow(item.order_id)" title="退单/终止">
												<span class="fa-stack">
												<i class="fa fa-square fa-stack-2x"></i>
												<i class="fa  fa-stack-1x fa-inverse  fa-mail-reply "></i>
												</span>
                                    </a>
                                    <!--<a  class="table-link default " ng-if="item.status == '完成' || item.status == '已回访'|| item.status == '终止订单' || item.status == '服务中'" title="退单/终止">
                                        <span class="fa-stack">
                                        <i class="fa fa-square fa-stack-2x"></i>
                                        <i class="fa  fa-stack-1x fa-inverse  fa-mail-reply "></i>
                                        </span>
                                    </a>-->

                                    <!--<a class="btn btn-default" ng-if="item.status == '完成' || item.status == '已回访'|| item.status == '终止订单' || item.status == '服务中'">退单/终止</a>-->

                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <ul class="pagination pull-right">
                        <li><a >总条数：{{count}}</a></li>
                        <li><a >总页数：{{totalPage}}</a></li>
                        <li><a ng-click="changePage(1)">首页</a></li>
                        <li><a ng-show="currentPage>1" ng-click="changePage(currentPage-1)"><i class="fa fa-chevron-left"></i></a></li>
                        <!--<li><span ng-show="frontdotShow">…</span></li>-->
                        <li ng-repeat="item in pageList" ng-click="changePage(item.number)" class="{{item.active}}"><a>{{item.number}}</a></li>
                        <!--<li><span ng-show="backdotShow">…</span></li>-->
                        <li><a ng-show="currentPage<totalPage" ng-click="changePage(currentPage+1)"><i class="fa fa-chevron-right"></i></a></li>
                        <li><a ng-click="changePage(totalPage)">尾页</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <!--代码写在这里  end-->
</div>








<div class="md-overlay"></div>
<script src="../default/js/modernizr.custom.js"></script>
<script src="../default/js/classie.js"></script>
<script src="../default/js/modalEffects.js"></script>
<script type="text/javascript">
    function init() {
        var overlay = document.querySelector('.md-overlay');
        [].slice.call(document.querySelectorAll('.md-trigger')).forEach(function(el, i) {
            var modal = document.querySelector('#' + el.getAttribute('data-modal')),
                    close = modal.querySelector('.md-close');
            function removeModal(hasPerspective) {
                classie.remove(modal, 'md-show');
                if (hasPerspective) {
                    classie.remove(document.documentElement, 'md-perspective');
                }
            }

            function removeModalHandler() {
                removeModal(classie.has(el, 'md-setperspective'));
            }
            el.addEventListener('click', function(ev) {
                classie.add(modal, 'md-show');
                overlay.removeEventListener('click', removeModalHandler);
                overlay.addEventListener('click', removeModalHandler);
                if (classie.has(el, 'md-setperspective')) {
                    setTimeout(function() {
                        classie.add(document.documentElement, 'md-perspective');
                    }, 25);
                }
            });
            close.addEventListener('click', function(ev) {
                ev.stopPropagation();
                removeModalHandler();
            });
            $(document).keyup(function(e) {
                if (e.keyCode == 27) {
                    e.stopPropagation();
                    removeModalHandler();
                }
            });
        });
    }
    function closeMod(){
        $(".md-close").click();
    }

</script>